#include <iostream>

using namespace std;
#define int long long
int last[26];
signed main()
{
    string s; cin >> s;
    s = ' ' + s;
    int res = 0;
    int n = s.size();
    for(int i = 1;i < n;i ++)
    {
        res += (n - i) * (i - last[s[i] - 'a']);
        last[s[i] - 'a'] = i;
    }
    cout << res << endl;
    return 0;
}